﻿@namespace MatBlazor
@typeparam T
@inherits BaseMatInputTextComponent<T>

<label class="@ClassMapper.AsString()" style="@StyleMapper.AsString()" @ref="Ref">

    @if (!Outlined)
    {
        <span class="mdc-text-field__ripple"></span>
    }

    @if (Icon != null && !IconTrailing)
    {
        <i class="material-icons mdc-text-field__icon mdc-text-field__icon--leading" tabindex="@(IconOnClick.HasDelegate ? "0" : null)" onclick="@IconOnClick">@Icon</i>
    }

    @if (TextArea)
    {
        <textarea style="@InputStyle" @ref="InputRef"  placeholder="@PlaceHolder" required=@Required class="@InputClassMapper.AsString()" id="@Id" @bind="@CurrentValueAsString" aria-label="@Label" oninput="@OnInput" @onkeydown="@OnKeyDownEvent()" onkeyup=@OnKeyUp onfocusout="@OnFocusOutEvent.Value" onkeypress="@OnKeyPress" onfocus="@OnFocusEvent.Value" disabled=@Disabled readonly="@InputTextReadOnly()" @attributes="Attributes" />
    }
    else
    {
        <input style="@InputStyle" @ref="InputRef" type="@Type" placeholder="@PlaceHolder" required=@Required class="@InputClassMapper.AsString()" id="@Id" @bind="@CurrentValueAsString" aria-label="@Label" oninput="@OnInput" @onkeydown="@OnKeyDownEvent()" onkeyup=@OnKeyUp onfocusout=@OnFocusOutEvent.Value onkeypress="@OnKeyPress" onfocus="@OnFocusEvent.Value" disabled=@Disabled readonly="@InputTextReadOnly()" @attributes="Attributes"/>
    }


    @if (Icon != null && IconTrailing)
    {
        <i class="material-icons mdc-text-field__icon mdc-text-field__icon--trailing" tabindex="@(IconOnClick.HasDelegate ? "0" : null)" onclick="@IconOnClick">@Icon</i>
    }

    @if (!FullWidth && Outlined)
    {
        <div class="mdc-notched-outline">
            <span class="mdc-notched-outline__leading"></span>
            @if (Label != null)
            {
                <span class="mdc-notched-outline__notch">
                    <span class="@LabelClassMapper.AsString()" for="@Id">@Label</span>
                </span>
            }
            <div class="mdc-notched-outline__trailing"></div>
        </div>
    }
    else
    {
        if (Label != null)
        {
            <span class="@LabelClassMapper.AsString()" for="@Id">@Label</span>
        }
        <span class="mdc-line-ripple"></span>
    }

    @BuildRenderTreeChildContent()

</label>
@if (HelperText != null)
{
    <MatHelperText HelperTextPersistent="@HelperTextPersistent" 
                   HelperTextValidation="@HelperTextValidation" 
                   HelperText="@HelperText"/>
}